<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            box-sizing: border-box;
        }

        .container {
            height: 300px;
            background-color: red;
            width: 80%;
            margin: 0 auto;
            padding: 100px;
            border: 3px solid #3498db;
            /* position: relative; */
        }

        .item {
            border: inherit;
            background: lightblue;
            width: 100%;
            /* 父组件没有设置高度，100%就是无效，即使子组件设置了高度 */
            height: 100%;
        }

        .item1 {
            /* 绝对定位的元素计算时宽度需要加上父元素的padding区域 */
            width: 50%;
            height: 100px;
            background: green;
            position: absolute;
            /* margin-top: 10%;
            padding-top: 10%; */
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- <div class="item1"></div> -->
        <div class="item"></div>
    </div>
</body>

</html>